//
//  JoinQuizDetailSubmitView.m
//  WanCaiC8
//
//  Created by tangang on 2018/3/14.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "JoinQuizDetailSubmitView.h"

@implementation JoinQuizDetailSubmitView{
    UIButton    *btnClean;
    QXLable     *labSelect;
    UIButton    *btnSubmit;
}

- (instancetype)init{
    if (self=[super init]) {
        WS(weakSelf);
        self.backgroundColor=[UIColor whiteColor];
        btnClean=[[UIButton alloc]init];
        [btnClean setTitle:@" 清空" forState:UIControlStateNormal];
        [btnClean setTitleColor:DEFAULTTEXTBLACKCOLOR forState:UIControlStateNormal];
        [btnClean setImage:[UIImage imageNamed:@"clean"] forState:UIControlStateNormal];
        [btnClean addTarget:self action:@selector(onclockClean) forControlEvents:UIControlEventTouchUpInside];
        [btnClean.titleLabel setFont:[UIFont systemFontOfSize:14]];
        [self addSubview:btnClean];
        [btnClean mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(weakSelf);
            make.width.mas_equalTo(@80);
        }];
        
        labSelect =[[QXLable alloc]init];
        labSelect.textAlignment=NSTextAlignmentCenter;
        [self addSubview:labSelect];
        [labSelect mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(weakSelf);
            make.centerX.equalTo(weakSelf);
            make.width.mas_equalTo(@120);
        }];
        
        btnSubmit=[[UIButton alloc]init];
        [btnSubmit setTitle:@"确定" forState:UIControlStateNormal];
        [btnSubmit setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [btnSubmit.titleLabel setFont:[UIFont systemFontOfSize:14]];
        btnSubmit.backgroundColor=NAVCOLOR;
        btnSubmit.layer.masksToBounds=YES;
        btnSubmit.layer.cornerRadius=3.0;
        [btnSubmit addTarget:self action:@selector(onclickSubmit) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btnSubmit];
        [btnSubmit mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(weakSelf).with.offset(-10);
            make.top.equalTo(weakSelf).with.offset(5);
            make.bottom.equalTo(weakSelf).with.offset(-5);
            make.width.mas_equalTo(@70);
        }];
        
        UIView *lineView=[[UIView alloc]init];
        lineView.backgroundColor=DEFAULTBGCOLOR;
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(weakSelf);
            make.height.mas_equalTo(@.7);
        }];
    }
    return self;
}


- (void)setTotal:(NSInteger)total{
    _total=total;
    NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已选:  %ld注",total]];
    [attStr addAttribute:NSForegroundColorAttributeName value:NAVCOLOR range:NSMakeRange(attStr.length-4, 3)];
    labSelect.attributedText=attStr;
    
}

- (void)onclockClean{
    if (self.cleanBlock) {
        self.cleanBlock();
    }
}

- (void)onclickSubmit{
    if (self.submitBlock) {
        self.submitBlock();
    }
}

@end
